package com.amorcloud.pig.utils;

import com.amorcloud.pig.MyApp;
import com.amorcloud.pig.bean.CheckBean;

import java.util.List;

public class CheckDaoUtil {

    /**
     * 插入盘点数据
     *
     * @param check
     * @return
     */
    public static long insert(CheckBean check) {
        return MyApp.getDaoInstant().getCheckBeanDao().insert(check);
    }

    /**
     * 获取所有盘点数据
     *
     * @return
     */
    public static List<CheckBean> queryAllCheckData() {
        //return MyApp.getDaoInstant().getCheckBeanDao().loadAll();
        String where = "where CHECK_TYPE!=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "4");
    }

    public static List<CheckBean> queryAllSellData() {
        String where = "where CHECK_TYPE=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "4");
    }

    /**
     * 查询已经上传成功的盘点数据
     *
     * @return
     */
    public static List<CheckBean> queryUploadSuccessCheckData() {
        String where = "where UP_LOAD_SUCCESS=? and CHECK_TYPE!=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "1", "4");
    }

    public static List<CheckBean> queryUploadSuccessSellData() {
        String where = "where UP_LOAD_SUCCESS=? and CHECK_TYPE=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "1", "4");
    }

    /**
     * 查询上传失败的盘点数据
     *
     * @return
     */
    public static List<CheckBean> queryUploadFailCheckData() {
        String where = "where UP_LOAD_SUCCESS=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "0", "4");
    }

    public static List<CheckBean> queryUploadFailSellData() {
        String where = "where UP_LOAD_SUCCESS=? and CHECK_TYPE=?";
        return MyApp.getDaoInstant().getCheckBeanDao().queryRaw(where, "0", "4");
    }

    /**
     * 删除单条数据
     *
     * @param bean
     */
    public static void delete(CheckBean bean) {
        MyApp.getDaoInstant().getCheckBeanDao().delete(bean);
    }

    /**
     * 更新一条数据
     *
     * @param bean
     */
    public static void update(CheckBean bean) {
        MyApp.getDaoInstant().getCheckBeanDao().update(bean);
    }

}
